import Sortable from "sortablejs";

//列拖拽
function columnDrop(dropCol) {
  //获取dom节点
  const wrapperTr = document.querySelector(".el-table__header-wrapper tr");
  Sortable.create(wrapperTr, {
    animation: 180,
    delay: 0,
    onEnd: (evt) => {
      const oldItem = dropCol[evt.oldIndex - 1];
      dropCol.splice(evt.oldIndex - 1, 1);
      dropCol.splice(evt.newIndex - 1, 0, oldItem);
    },
  });
  return dropCol;
}

export default columnDrop;
